Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming exercises: Change the solution entry and testwise coverage editors to Monaco #9173

Merged
merged 21 commits into from
Aug 11, 2024

Conversation

pzdr7
Copy link
Contributor

@pzdr7 pzdr7 commented Aug 2, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I strictly followed the client coding and design guidelines.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

We want to replace Ace in Artemis with Monaco. The (presumably unused?) Code Hints feature relies on Ace to display & edit code snippets.

Description

  • Introduced Monaco into the solution entry modals and editor
  • Minor layout changes (moved the save/submit button)
  • The syntax highlighting of the code now depends on the file extension (instead of always being java)

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Programming exercise
  1. Log in to Artemis
  2. Navigate to course management > your course > exercises > your programming exercise
  3. Click "Hints". It should show you "No Exercise Hint found."
  4. Click "Generate code hints" (Note: You have to wait for the solution repository build to finish before doing this.)
  5. Click "Generate structural snippets"
  6. For one of the generated entries, click "View" and verify that the modal looks good.
  7. For one of the generated entries, click "Edit" and verify that the modal looks good. Make a change and save it, then verify that the change was actually saved.
  8. Click "Create manual fragment". Select a file and a test case, write the fragment and submit it. Verify in the list that your changes were saved correctly.
  9. Click "Next"
  10. Click "Generate Code Hints"
  11. Expand one of the code hints and check that it looks good.
  12. Edit one of the code hints and check that it looks good (Note: To save the code hint, you may have to enter a valid description at the top.). Verify that your changes are saved

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
manual-solution-entry-creation-modal.component.ts 90.9%
solution-entry.component.ts 100%
monaco-editor.component.ts 92%

Screenshots

Modals

image

image

image

Code hints + editing

image

image

Summary by CodeRabbit

  • New Features

    • Enhanced the manual solution entry modal with dynamic file selection updates and improved layout.
    • Integrated Monaco Editor for a more advanced code editing experience.
    • Added methods to manage content height and specify starting line numbers in the Monaco Editor.
  • Bug Fixes

    • Improved test coverage for the Monaco Editor's start line number functionality.
  • Documentation

    • Updated test cases to reflect the new editor technology and better verify component behaviors.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Aug 2, 2024
@pzdr7 pzdr7 temporarily deployed to artemis-test2.artemis.cit.tum.de August 3, 2024 11:16 — with GitHub Actions Inactive
@pzdr7 pzdr7 marked this pull request as ready for review August 3, 2024 11:32
@pzdr7 pzdr7 requested a review from a team as a code owner August 3, 2024 11:32
Copy link

coderabbitai bot commented Aug 3, 2024

Walkthrough

The overall changes introduce substantial enhancements to the Angular application, focusing on the transition from the Ace editor to the Monaco editor, which is central to improving solution entry management and editor interactions. Improvements in modal layouts, event handling, and responsive design are also significant. These updates aim to refine user experience, streamline code maintenance, and create a more dynamic and visually appealing editing environment.

Changes

Files Change Summary
.../manual-solution-entry-creation-modal/manual-solution-entry-creation-modal.component.html Added event handler for file selection and modified the modal layout for improved interactivity and visual organization. Introduced local reference for easier component access.
.../manual-solution-entry-creation-modal/manual-solution-entry-creation-modal.component.ts Introduced @ViewChild for SolutionEntryComponent, removed CodeHintService, and added onUpdateFilePath method for dynamic file path handling.
.../solution-entry-details-modal/solution-entry-details-modal.component.html Updated modal layout from horizontal to vertical for better alignment and space utilization.
.../code-hint-container.component.html Changed layout from horizontal to vertical, enhancing readability and organization of solution entries.
.../exercise-hint-shared.module.ts Replaced AceEditorModule with MonacoEditorModule to improve editor functionality.
.../solution-entry.component.html Replaced jhi-ace-editor with jhi-monaco-editor, enhancing editing experience and restructuring for a responsive design.
.../solution-entry.component.scss Introduced .solution-entry-editor class for styling solution entry components, improving visual separation and maintainability.
.../solution-entry.component.ts Transitioned to MonacoEditorComponent, restructured methods for better initialization and content management, enhancing overall functionality.
.../monaco-editor.component.ts Improved event handling for content height changes; introduced new methods for managing editor settings, enhancing responsiveness and configurability.
.../solution-entry.component.spec.ts Updated test suite to mock MonacoEditorComponent, refined logic for testing editor initialization and content changes, enhancing test coverage.
.../manual-solution-entry-creation-modal.component.spec.ts Added mock for SolutionEntryComponent and a new test case for file path changes to ensure proper editor setup.
.../monaco-editor.component.spec.ts Introduced new test case to verify correct initialization of line numbers in the Monaco editor, enhancing test coverage for this functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Modal
    participant SolutionEntry

    User->>Modal: Select file
    Modal->>SolutionEntry: onUpdateFilePath()
    SolutionEntry-->>Modal: Update editor with new file path
    Modal->>User: Display updated content
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 23956cd and 931018f.

Files selected for processing (2)
  • src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts (2 hunks)
  • src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.component.spec.ts (1 hunks)
Additional context used
Path-based instructions (2)
src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

Learnings (1)
src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.component.spec.ts (1)
Learnt from: pzdr7
PR: ls1intum/Artemis#8832
File: src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.ts:344-345
Timestamp: 2024-06-20T21:25:36.138Z
Learning: The Monaco editor uses 1-based line numbering, and this should be considered when handling line numbers in code related to this editor.
Additional comments not posted (1)
src/main/webapp/app/shared/monaco-editor/monaco-editor.component.ts (1)

167-169: Ensure accurate content height calculation.

The getContentHeight method correctly calculates the content height by adding the line height. Ensure that any changes to the editor's configuration that might affect line height are reflected here.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 3, 2024
@pzdr7 pzdr7 dismissed stale reviews from Jan-Thurner and coderabbitai via eabd2e4 August 6, 2024 14:08
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 6, 2024
edkaya
edkaya previously approved these changes Aug 6, 2024
Copy link
Contributor

@edkaya edkaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove after merge conflict

JohannesStoehr
JohannesStoehr previously approved these changes Aug 6, 2024
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove code after merge conflict

BBesrour
BBesrour previously approved these changes Aug 6, 2024
Copy link
Member

@BBesrour BBesrour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove code after merge conflict

@pzdr7 pzdr7 requested a review from Jan-Thurner August 6, 2024 15:39
Jan-Thurner
Jan-Thurner previously approved these changes Aug 6, 2024
Copy link
Contributor

@Jan-Thurner Jan-Thurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reprove after merge conflict

@pzdr7 pzdr7 added this to the 7.5.0 milestone Aug 10, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

@pzdr7 pzdr7 changed the title Programming exercises: Change the solution entry editor to Monaco Programming exercises: Change the solution entry and testwise coverage editors to Monaco Aug 11, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 11, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

@krusche krusche merged commit 24f225d into develop Aug 11, 2024
17 of 21 checks passed
@krusche krusche deleted the feature/programming-exercises/code-hint-monaco branch August 11, 2024 08:16
JohannesWt pushed a commit that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) ready for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants